<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier-html-xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/multiselect.css" />
<link rel="stylesheet" href="${aier_css_url}jc/chosen.css">
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/classes/common.css" />
<link rel="stylesheet" href="${aier_css_url}social/classes/cmanage.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/xxs.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/ja.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/multiselect.js"></script>
<script type="text/javascript">
	var global_suffix = "${aier_suffix}", global_url = "${aier_url}", global_uri = "${aier_uri}", global_urijs = "${aier_urijs}", 
		global_cid = "${cid}",global_tid = "${tid}";
</script>
</head>
<!-- 班级成员审核页面 -->
<body>
	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user"
		executeResult="true"></s:action>

	<!-- 正文 -->
	<div id="hfContent" class="ar-content">
		<div class="content-main">
			<!-- 班级名称栏 -->
			<s:action name="ccomm_classesMTitle" namespace="/classes"
				executeResult="true"></s:action>
			<div class="main-content wrap-bg clearfix">
				<!-- 左侧栏 -->
				<s:action name="ccomm_classesMLeft" namespace="/classes"
					executeResult="true"></s:action>
				<!-- 右侧内容 -->
				<div class="ae-right">
					<div class="right-main">
						<div class="right-main-top">
							<div class="binfo-title">
								<span>成员审核</span>
							</div>
							<div class="right-line"></div>
						</div>
						<div class="right-main-c">
							<div id="tabs">
								<ul>
									<li><a href="#audPar" id = "audpar">家长申请审核</a></li>
									<li><a href="#audTea" id = "audtea">教师申请审核</a></li>
								</ul>

								<div id="audPar">
								<!-- 消息块 -->
									<div class="info-tab01" id="classstudent">
										
									</div>
								</div>
								
								<div id="audTea">
									<div class="info-tab01" id="classteacher">
										
									</div>
								</div>

							</div>
						</div>
					</div>
					<div id = "page"></div>
				</div>
			</div>

		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>
	<!-- 确认是否同意弹出层 -->
	<div id="compPrompt" title="提示">
		<span>确定同意该申请码?</span>
	</div>
</body>
<script type="text/javascript">
	$("#tabs").tabs();
	
	var ppage = 1;       // 家长列表当前页
	var tpage = 1;       // 教师列表当前页
    var page_size = 1;  // 每页的记录数
	
	$(document).ready(function() {
		load_p(ppage);
	});


//===================================================
    $("#audpar").click(function () {
        load_p(ppage);
    });
	//家长
	function load_p(nowppage){
	    ppage = nowppage;
		var funadd2 = function(data){
			if (data.s == 1) {
				if(data.requestParentList != null && data.requestParentList.length > 0){
					var msg_html = "";		
					for( var i = 0; i < data.requestParentList.length; i++ ){
						var name_student = data.requestParentList[i].name_student;
						var nickname = data.requestParentList[i].user_parent.nickname;
						var headimg = data.requestParentList[i].user_parent.headimg;
						var relation = data.requestParentList[i].relation;
						var content = data.requestParentList[i].content;
						var ctime_str = data.requestParentList[i].ctime_str;
						var rpid = data.requestParentList[i].rpid;
						msg_html += "<div class='exam clearfix'><dl class='e-user'><dt><img src='${get_picturl_url}small/"+headimg+"' class='face'></dt>"
								+ "<dd><span>"+name_student+"的"+relation+"</span><span><a href='javascript:;'>"+nickname+"</a></span></dd></dl>"
								+"<div class='e-info'><p>申请加入班级<span>"+ctime_str+"</span></p><p class='apinfo'>"+content+"</p>"
								+"</div><div class='e-btns'><a href='javascript:;' class='button' onclick='upreq_pyes("+rpid+");' ><em>同意</em></a>&nbsp;&nbsp;"
								+"<a href='javascript:;' class='button e-btns-no' onclick='upreq_pno("+rpid+");' ><em>拒绝</em></a></div></div>";
					}
					$("#classstudent").html(msg_html);
					ppage = data.page;
					// 更新分页显示
                    toLoadPage(ppage, page_size, data.page_count, data.count, "page", "load_p", null, null); 
				}else{
					$("#classstudent").html("");
				}
			} else {
				$("#classstudent").html("");
			}
			if (isnull($("#classstudent").html())) {
                $("#page").css("display","none");
            } else {
                $("#page").css("display","block");
            }
		};
		exeAjax(ajaxUrl("${aier_url}${aier_urijs}cmaudit_searchRequestParentList${aier_suffix}"), funadd2, {
		"cid":global_cid,
		"tid":global_tid,
		"page":ppage,
		"page_size":page_size});		
	}
	
	//确认提示弹出层
	
	function upreq_pyes(rpid){
		
		$( "#compPrompt" ).dialog({
			modal: true,
			resizable: false,
			buttons: {
				"确定": function() {
					var fun = function(data) {
						load_p(ppage);
						$( "#compPrompt" ).dialog( "close" );
					};
					exeAjax(ajaxUrl("${aier_url}${aier_urijs}cmaudit_updateRequestParentState${aier_suffix}"), fun, 
						{"rpid" :rpid,"state":1,"tid":global_tid});
				    
					},"取消": function() {
					$( this ).dialog( "close" );
				}
			}
			});
	}
	
	function upreq_pno(rpid){
		$( "#compPrompt" ).dialog({
			modal: true,
			resizable: false,
			buttons: {
				"确定": function() {
					var fun = function(data) {
						load_p(ppage);
						$( "#compPrompt" ).dialog( "close" );
					};
					exeAjax(ajaxUrl("${aier_url}${aier_urijs}cmaudit_updateRequestParentState${aier_suffix}"), fun, 
						{"rpid" :rpid,"state":2,"tid":global_tid});
					},"取消": function() {
					$( this ).dialog( "close" );
				}
			}
			});	
	}	
	
//===================================================	
    $("#audtea").click(function () {
        load_t(tpage);
    });
	//教师
	function load_t(nowtpage){
	    tpage = nowtpage;
		var funadd2 = function(data){
			if (data.s == 1) {
				if(data.requestTeacherList.length > 0){
					var msg_html = "";		
					for( var i = 0; i < data.requestTeacherList.length; i++ ){
						var tname = data.requestTeacherList[i].tname;
						var headimg = data.requestTeacherList[i].user.headimg;
						var content = data.requestTeacherList[i].content;
						var ctime_str = data.requestTeacherList[i].ctime_str;
						var rtid = data.requestTeacherList[i].rtid;
						msg_html += "<div class='exam clearfix'><dl class='e-user'><dt><img src='${get_picturl_url}small/"+headimg+"' class='face'></dt>"
								+ "<dd><span></span><span><a href='javascript:;'>"+tname+"</a></span></dd></dl>"
								+"<div class='e-info'><p>申请加入班级<span>"+ctime_str+"</span></p><p class='apinfo'>"+content+"</p>"
								+"</div><div class='e-btns'><a href='javascript:;' class='button' onclick='upreq_tyes("+rtid+");' ><em>同意</em></a>"
								+"<a href='javascript:;' class='button e-btns-no' onclick='upreq_tno("+rtid+");' ><em>拒绝</em></a></div></div>";
					}
					$("#classteacher").html(msg_html);
					// 更新分页显示
					tpage = data.page;
                    toLoadPage(tpage, page_size, data.page_count, data.count, "page", "load_t", null, null);
				}else{
					$("#classteacher").html("");
				}
			} else {
				$("#classteacher").html("");
			}
			if (isnull($("#classteacher").html())) {
                $("#page").css("display","none");
            } else {
                $("#page").css("display","block");
            }
		};
		exeAjax(ajaxUrl("${aier_url}${aier_urijs}cmaudit_searchRequestTeacherList${aier_suffix}"), funadd2, {
		"cid":global_cid,
		"tid":global_tid,
		"page":tpage,
		"page_size":page_size});		
	}
	
	function upreq_tyes(rtid){
		if(confirm("确定同意该申请码?")){
			var fun = function(data) {
				load_t(tpage);
			};
			exeAjax(ajaxUrl("${aier_url}${aier_urijs}cmaudit_updateRequestTeacherState${aier_suffix}"), fun, 
				{"rtid" :rtid,"state":1,"tid":global_tid});		
		}
	}
	
	function upreq_tno(rtid){
		if(confirm("确定拒绝该申请码?")){
			var fun = function(data) {
				load_t(tpage);
			};
			exeAjax(ajaxUrl("${aier_url}${aier_urijs}cmaudit_updateRequestTeacherState${aier_suffix}"), fun, 
				{"rtid" :rtid,"state":2,"tid":global_tid});
		}			
	}	
	
</script>
</html>